package com.chis.sms.smsServer;

/**
 * @Description webservice接口
 * @Company zwx
 * @author jw
 * @version 2018年8月14日
 */
public class SmsServerPortBindingStub extends org.apache.axis.client.Stub implements SmsServer {
	/**类集合*/
	private java.util.Vector cachedSerClasses = new java.util.Vector();
	/**服务名称集合*/
	private java.util.Vector cachedSerQNames = new java.util.Vector();
	/**服务工厂集合*/
	private java.util.Vector cachedSerFactories = new java.util.Vector();
	/**工厂描述集合*/
	private java.util.Vector cachedDeserFactories = new java.util.Vector();

	/**服务数组*/
	private static org.apache.axis.description.OperationDesc[] _operations;

	static {
		_operations = new org.apache.axis.description.OperationDesc[1];
		_initOperationDesc1();
	}

	/**
	 * 初始化服务数组
	 */
	private static void _initOperationDesc1() {
		org.apache.axis.description.OperationDesc oper;
		org.apache.axis.description.ParameterDesc param;

		oper = new org.apache.axis.description.OperationDesc();
		oper.setName("smsUpLoad");
		param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "UpString"), org.apache.axis.description.ParameterDesc.IN,
				new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
		param.setOmittable(true);
		oper.addParameter(param);
		param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "UserCode"), org.apache.axis.description.ParameterDesc.IN,
				new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
		param.setOmittable(true);
		oper.addParameter(param);
		param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "PassWord"), org.apache.axis.description.ParameterDesc.IN,
				new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
		param.setOmittable(true);
		oper.addParameter(param);
		oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
		oper.setReturnClass(int.class);
		oper.setReturnQName(new javax.xml.namespace.QName("", "return"));
		oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
		oper.setUse(org.apache.axis.constants.Use.LITERAL);
		_operations[0] = oper;

	}

	public SmsServerPortBindingStub() throws org.apache.axis.AxisFault {
		this(null);
	}

	public SmsServerPortBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
		this(service);
		super.cachedEndpoint = endpointURL;
	}

	public SmsServerPortBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
		if (service == null) {
			super.service = new org.apache.axis.client.Service();
		} else {
			super.service = service;
		}

	}

	/**
	 * 创建服务
	 * @return 服务
	 * @throws java.rmi.RemoteException 异常
	 */
	protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {
		try {
			org.apache.axis.client.Call tempcall = super._createCall();
			if (super.maintainSessionSet) {
				tempcall.setMaintainSession(super.maintainSession);
			}
			if (super.cachedUsername != null) {
				tempcall.setUsername(super.cachedUsername);
			}
			if (super.cachedPassword != null) {
				tempcall.setPassword(super.cachedPassword);
			}
			if (super.cachedEndpoint != null) {
				tempcall.setTargetEndpointAddress(super.cachedEndpoint);
			}
			if (super.cachedTimeout != null) {
				tempcall.setTimeout(super.cachedTimeout);
			}
			if (super.cachedPortName != null) {
				tempcall.setPortName(super.cachedPortName);
			}
			java.util.Enumeration keys = super.cachedProperties.keys();
			while (keys.hasMoreElements()) {
				String key = (String) keys.nextElement();
				tempcall.setProperty(key, super.cachedProperties.get(key));
			}
			// All the type mapping information is registered
			// when the first call is made.
			// The type mapping information is actually registered in
			// the TypeMappingRegistry of the service, which
			// is the reason why registration is only needed for the first call.
			synchronized (this) {
				if (firstCall()) {
					// must set encoding style before registering serializers
					tempcall.setEncodingStyle(null);
					for (int i = 0; i < cachedSerFactories.size(); ++i) {
						Class cls = (Class) cachedSerClasses.get(i);
						javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames.get(i);
						Object x = cachedSerFactories.get(i);
						if (x instanceof Class) {
							Class sf = (Class) cachedSerFactories.get(i);
							Class df = (Class) cachedDeserFactories.get(i);
							tempcall.registerTypeMapping(cls, qName, sf, df, false);
						} else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) {
							org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) cachedSerFactories.get(i);
							org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) cachedDeserFactories.get(i);
							tempcall.registerTypeMapping(cls, qName, sf, df, false);
						}
					}
				}
			}
			return tempcall;
		} catch (Throwable t) {
			throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
		}
	}

	/**
	 * 上传短信信息
	 * @param upString 短信压缩串，需进行GZIP解压缩
	 * @param userCode 用户名
	 * @param passWord 密码
	 * @return 0：成功 ，-1：失败
	 * @throws java.rmi.RemoteException 异常
	 */
	public int smsUpLoad(String upString, String userCode, String passWord) throws java.rmi.RemoteException {
		if (super.cachedEndpoint == null) {
			throw new org.apache.axis.NoEndPointException();
		}
		org.apache.axis.client.Call tempcall = createCall();
		tempcall.setOperation(_operations[0]);
		tempcall.setUseSOAPAction(true);
		tempcall.setSOAPActionURI("");
		tempcall.setEncodingStyle(null);
		tempcall.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
		tempcall.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
		tempcall.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
		tempcall.setOperationName(new javax.xml.namespace.QName("http://service.sms.chis.com/", "smsUpLoad"));

		setRequestHeaders(tempcall);
		setAttachments(tempcall);
		try {
			Object resp = tempcall.invoke(new Object[] { upString, userCode, passWord });

			if (resp instanceof java.rmi.RemoteException) {
				throw (java.rmi.RemoteException) resp;
			} else {
				extractAttachments(tempcall);
				try {
					return ((Integer) resp).intValue();
				} catch (Exception exception) {
					return ((Integer) org.apache.axis.utils.JavaUtils.convert(resp, int.class)).intValue();
				}
			}
		} catch (org.apache.axis.AxisFault axisFaultException) {
			throw axisFaultException;
		}
	}

}
